package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.HallType;
import com.woniu.cinema.service.HallTypeService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 影厅类型Controller
 * 
 * @author yy
 * @date 2021-04-16
 */
@RestController
@RequestMapping("/cinema/halltype")
public class HallTypeController extends BaseController
{
    @Autowired
    private HallTypeService hallTypeService;

    /**
     * 查询影厅类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HallType hallType)
    {
        startPage();
        List<HallType> list = hallTypeService.selectHallTypeList(hallType);
        return getDataTable(list);
    }

    /**
     * 导出影厅类型列表
     */
    @Log(title = "影厅类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HallType hallType)
    {
        List<HallType> list = hallTypeService.selectHallTypeList(hallType);
        ExcelUtil<HallType> util = new ExcelUtil<HallType>(HallType.class);
        return util.exportExcel(list, "halltype");
    }

    /**
     * 获取影厅类型详细信息
     */
    @GetMapping(value = "/{htId}")
    public AjaxResult getInfo(@PathVariable("htId") Long htId)
    {
        return AjaxResult.success(hallTypeService.selectHallTypeById(htId));
    }

    /**
     * 新增影厅类型
     */
    @Log(title = "影厅类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HallType hallType)
    {
        return toAjax(hallTypeService.insertHallType(hallType));
    }

    /**
     * 修改影厅类型
     */
    @Log(title = "影厅类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HallType hallType)
    {
        return toAjax(hallTypeService.updateHallType(hallType));
    }

    /**
     * 删除影厅类型
     */
    @Log(title = "影厅类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{htIds}")
    public AjaxResult remove(@PathVariable Long[] htIds)
    {
        return toAjax(hallTypeService.deleteHallTypeByIds(htIds));
    }
}
